﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
int main()
{
//	int ar[] = { 0,1, 2, 3, 4,  5, 6, 7, 8, 9 };
//	int n = sizeof(ar) / sizeof(int);
//	std::list<int> mylist(ar, ar + n);
//	std::list<int>::iterator it = mylist.begin();
//	while (it != mylist.end())
//	{
//		std::cout << *it << " ";
//		it++;
//	}
//	std::cout << std::endl;
//}

//﻿int main()
//{
//	﻿int main()
//	{
		int array[] = { 1, 2, 3, 4, 0, 5, 6, 7, 8, 9 };
		int n = sizeof(array) / sizeof(int);
		list<int> mylist(array, array + n);
		auto it = mylist.begin();
		while (it != mylist.end())
		{
			if (*it != 0)
				cout << *it << " ";
			else
				it = mylist.erase(it);
			++it;
		}
		return 0;
	}